<template>
    <div>
        <Header v-show="flag" />
        <router-view/>
        <Footer v-show="flag"/>
    </div>
</template>

<script>
import Header from './header.vue'
import Footer from './footer.vue'
export default {
  components: { Header, Footer },
  data() {
      return {
          flag:true
      }
  },
   watch: {
        $route(to) {
            // to 和 from 都是 路由信息对象
            if(to.path=='/'){
                this.flag = false
            }
            console.log(123);
        }
    }
    }
</script>

<style scoped>

</style>